<div class="main-wrap">

        <div class="crumb-wrap">
            <div class="crumb-list"><i class="icon-font"></i><a href="index.html">首页</a><span class="crumb-step">&gt;</span><span class="crumb-name">片库管理</span></div>
        </div>
        <div class="search-wrap">
           <td>&nbsp&nbsp;&nbsp;&nbsp;<input class="btn btn-primary btn2" name="sub" value="批量更新短链接" onclick="piliang()" type="button"></td>

		   <script>
		      
			  function piliang(){
			  
			     layer.msg('批量生成中,请勿刷新', {
				  icon: 16
				  ,shade: 0.01,time:22222222
				});
			  
			     $.post("{:U('Pianku/piliang')}",function(re){
				    layer.closeAll();
					if(re==1){
					
					layer.alert('生成成功',function(){
					
					
					  location.reload();
					
					});
					
					}else{
					
					alert('失败');
					
					
					}
				 
				 
				 
				 })
			  
			  
			  }
		     
		   </script>
        </div>
        <div class="result-wrap">
            <form name="myform" id="myform" action="{:U('Pianku/daochu')}" method="post">
                
                <div class="result-content">
                    <table class="result-tab" width="100%">
                        <tr>
						    <th>
							<a id="q1" style="cursor:pointer;" onclick="quanxuan()">全选</a>
							<a style="display:none;cursor:pointer;" id="q2"  onclick="quanbuxuan()">取消全选</a>
							</th>
                            <th>影片id</th>
							<th>详情[点击看详细]</th>
							<th>价格设置[直接修改即可]</th>
							<th>短连接</th>
							
							<th>资源属性</th>
							<th>盈利</th>
                            <th>操作</th>
                        </tr>
						
						<script>
						   
						   function quanxuan(){
						   
						     $('input').prop('checked',true);
						     
							 $('#q1').css('display','none');
							  $('#q2').css('display','block');
						   
						   }
						   
						   
						   function quanbuxuan(){
						   
						      $('input').prop('checked',false);
							  
							  	 $('#q2').css('display','none');
							  $('#q1').css('display','block');
						   
						   }
						   
						
						</script>
						
                        <foreach name="re" item="v">
                        <tr>
						   <td>
                                <input name="ids[]" value="{$v.id}" type="checkbox">
                               
                            </td>
                           <td>{$v.id}</td>
						   <TD>
						   	   <a onclick="datu({$v.pid})" style="cursor:pointer;">
								{$v.title}
							   </a>
						   </TD>
						   <td>
						   
						   <input type="text" style="width:38px;" onblur="saveprice({$v.id })" id="money{$v.id}" value="{$v.price}"/>元
						   </td>
						   <td>
						   {$v.url}</td>
						  
						   <td>{$v.shuxing}</td>
						   <td>{$v.yingli}元 | <a href="{:U('Pianku/xiangxi',array('id'=>$v['id']))}">详细</a></td>
						   <td>
						    <a style="cursor:pointer;" onclick="del({$v.id})">删除该打赏链接</a>
							  
						   </td>
                        </tr>
						</foreach>
						<tr>
						   
						   <td>
						       <a onclick="daochu()" style="cursor:pointer;">批量导出链接</a><br/>
							   <a onclick="shanchu()" style="cursor:pointer;">批量删除链接</a>
						   </td>
						 <input type="hidden" id="leixing" name="leixing" value=""/>
						</tr>
                    </table>
                    <div class="list-page"> {$page}</div>
                </div>
            </form>
        </div>
    </div>
	<script>
	
	   function daochu(){
	   
	     $('#leixing').val(0);
	   
	     $('#myform').submit();
	   
	   }
	   
	   
	   function shanchu(){
	   
	   
		   if(confirm('您确定删除吗')){
		   
			 $('#leixing').val(1);
		   
			 $('#myform').submit();
		   }
	   
	   }
	   
	
	
	   function saveprice(i){
	   
	     var price=$('#money'+i).val();
		 
		// alert(price);
		 
		 $.post("{:U('Pianku/saveprice')}",{"price":price,"id":i},function(re){
		   
		   if(re==1){
		   
		     layer.tips('修改成功', '#money'+i);
		   
		   }else{
		   
		     alert('修改失败');
		   
		   }
		 
		 
		 })
	   
	   
	   }
	
	  
	    function del(i){
		
		  if(confirm('您确定从片库删除此影片吗')){
		    
			$.post("{:U('Pianku/del')}",{"id":i},function(re){
			  
			  if(re==1){
			    
				alert('删除成功');
			    location.reload();
			  }else{
			  
			    alert('删除失败');
			  }
			
			
			})
		  
		  
		  }
		
		}
	  
	    function datu(i){
			  layer.open({
				  type: 2,
				  title: '视频详情',
				  shadeClose: true,
				  shade: 0.8,
				  area: ['80%', '90%'],
				  content: '{:U("Pianku/big")}?id='+i //iframe的url
				}); 
			}
	
	</script>
	